package com.cug.nageoffer.user.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cug.nageoffer.model.entity.UserStar;
import com.cug.nageoffer.model.vo.Result;
import com.cug.nageoffer.model.vo.ResultCodeEnum;
import com.cug.nageoffer.user.mapper.UserStarMapper;
import com.cug.nageoffer.user.service.UserStarService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserStarServiceImpl extends ServiceImpl<UserStarMapper, UserStar> implements UserStarService {
    @Override
    public Result<String> star(UserStar requestParam) {
        save(requestParam);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }

    @Override
    public Result<String> unStar(Integer id) {
        removeById(id);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }

    @Override
    public Result<List<UserStar>> queryStar(Integer userId) {
        List<UserStar> starList = query().eq("user_id", userId).list();
        return Result.build(starList,ResultCodeEnum.SUCCESS);
    }
}
